﻿using Architecture.Domain.Service;
using Architeture.Domain;
using MediatR;
using RBAC.ZhuBoLin.Application.Command.RoleCommand;

namespace RBAC.ZhuBoLin.Application.CommandHandlers.RoleHandler
{
    public class UserRoleCreateCommandHandler : IRequestHandler<UserRoleCreateCommand, int>
    {
        private readonly IUserService _userService;

        public UserRoleCreateCommandHandler(IUserService userService)
        {
            _userService = userService;
        }

        public async Task<int> Handle(UserRoleCreateCommand request, CancellationToken cancellationToken)
        {
            return await _userService.UserRoleAdd(new UserRoleInfo() { UserInfoid = request.UserInfoid, RoleInfoid = request.RoleInfoid });
        }
    }
}
